package com.example.shuiyin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.shuiyin.entity.ProcessRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProcessRecordMapper extends BaseMapper<ProcessRecord> {
    
    @Select("SELECT * FROM process_records WHERE user_id = #{userId} ORDER BY created_at DESC")
    IPage<ProcessRecord> findByUserIdOrderByCreatedAtDesc(Page<?> page, @Param("userId") Long userId);
    
    @Select("SELECT * FROM process_records WHERE user_id = #{userId} ORDER BY created_at DESC LIMIT 10")
    List<ProcessRecord> findTop10ByUserIdOrderByCreatedAtDesc(@Param("userId") Long userId);
    
    @Select("SELECT * FROM process_records WHERE id = #{id} AND user_id = #{userId}")
    ProcessRecord findByIdAndUserId(@Param("id") Long id, @Param("userId") Long userId);

    Page<ProcessRecord> selectPageByUserId(Page<ProcessRecord> page, @Param("userId") Long userId);
    List<ProcessRecord> selectRecentByUserId(@Param("userId") Long userId, @Param("limit") int limit);
} 